package org.meetunexpectedly.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

import java.util.Date;

/**
 * @Description:
 * @Author: pupil
 * @Date: 2024/08/07 下午 9:47
 */
@Configuration
public class AutoSetDateFieldConfig implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("gmtCreated",new Date(),metaObject);
        this.setFieldValByName("gmtUpdated",new Date(),metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("gmtUpdated",new Date(),metaObject);
    }
}
